package com.difsonapps.android.marker.beans;

import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;
import android.util.Log;

public class Like  implements Parcelable{
	private int id;
	private User user;
    private String created_at, modified_at;
    private String userName, description, userImage, timestamp;
    
    private String relativeDate = "";
	

	
	public static Like parseFromJsonObject(JSONObject json){
		if(json==null || !json.has("id")) return null;
		Like result = new Like();
		try {
			result.setId(json.getInt("id"));
			//result.setValue(json.getInt("value"));
			//result.setComment(json.getString("comment"));
			result.setCreated_at(json.getString("created_at"));
			result.setModified_at(json.getString("modified_at"));
			result.setUser(User.parseFromJsonObject(json.getJSONObject("user")));
		} catch (JSONException e) {
			e.printStackTrace();
			Log.e("Parse Like From JSON", e.getMessage());
			return null;
		}
		return result;
	}
	
    public Like() {
		super();
	}

	

	public int getId() {
		return id;
	}



	public void setId(int id) {
		this.id = id;
	}



	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}
	

	public String getCreated_at() {
		return created_at;
	}

	public void setCreated_at(String created_at) {
		this.created_at = created_at;
	}

	public String getModified_at() {
		return modified_at;
	}

	public void setModified_at(String modified_at) {
		this.modified_at = modified_at;
	}
	
	public String getRelativeDate() {
		return relativeDate;
	}

	public void setRelativeDate(String relativeDate) {
		this.relativeDate = relativeDate;
	}


	public String getUserName() {
		return userName;
	}



	public void setUserName(String userName) {
		this.userName = userName;
	}



	public String getDescription() {
		return description;
	}



	public void setDescription(String description) {
		this.description = description;
	}



	public String getUserImage() {
		return userImage;
	}



	public void setUserImage(String userImage) {
		this.userImage = userImage;
	}



	public String getTimestamp() {
		return timestamp;
	}



	public void setTimestamp(String timestamp) {
		this.timestamp = timestamp;
	}



	public Like(Parcel in){
		this();
		this.id = in.readInt();
		this.userName = in.readString();
		this.userImage = in.readString();
		this.timestamp = in.readString();
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(id);
		dest.writeString(userName);
		dest.writeString(userImage);
		dest.writeString(timestamp);
	}	
	
	public static final Parcelable.Creator<Like> CREATOR = new
		Parcelable.Creator<Like>() {
			@Override
			public Like createFromParcel(Parcel source) {
				return new Like(source);
			}
			@Override
			public Like[] newArray(int size) {
				return new Like[size];
		}
	};

	@Override
	public int describeContents() {
		return 0;
	}
    

}
